function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }

function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }

var resourceVo = {};
var permission = {};
var deduplication = "false";
var listTable;
/**
 * 初始化定制平台资源
 * @param resourceId
 * @returns
 */

function initResourceList(resourceId) {
  initOneResourceData(resourceId, resourceVo.menuId, function (data) {
    if (data.resourceNavurl) {
      $("#queryIframe").show();
      $(".container").hide();
      $("#queryIframe").attr("src", _ctxPath + data.resourceNavurl);
      return;
    }

    $("#batchResult").hide();
    var pending = 0; // 草稿箱显示批量收文进度，这个值是预制的，固定值

    if (resourceId === "-2239963480379736030") {
      pending = showProcessingData();
    }

    _initResourceVo(data, resourceId);

    initApplyList(); // 等工具栏加载完毕再调整基础查询的搜索框位置

    if (resourceId === "-2239963480379736030" && pending > 0) {
      adjustSearchPosition();
    }
  });
}
/**
 * 查看批量收文生成进度
 */


function showProcessingData() {
  var result = callBackendMethod("govdocAManager", "queryPendingBatchReceiveData");
  console.log(result); // 待处理数

  var pending = result["pending"]; // 待处理数据大于0的时候才需要显示。

  if (pending > 0) {
    // 上传数
    var replacement = result["replacement"]; // 消息模板

    var template = result["message"];
    var content = template.replace("%count%", "<span class='num'>" + replacement + "</span>");
    var closeHtml = "<span class='close' onclick='hideBatchResult()'>X</span>";
    $("#batchResult").html(content + closeHtml).show();
  }

  return pending;
}
/**
 * 当搜索框是基础查询时，调整搜索框位置
 */


function adjustSearchPosition() {
  var search = $(".common_search.common_search_condition"); // 如果普通搜索框存在，则调整搜索框位置

  if (search.length == 1) {
    search.css("top", search.offset().top + 36 + 'px');
  }
}
/**
 * 当关闭批量收文进度提示时，隐藏进度提示并调整基础查询搜索框位置
 */


function hideBatchResult() {
  $("#batchResult").hide();
  var search = $(".common_search.common_search_condition");

  if (search.length == 1) {
    search.css("top", search.offset().top - 36 + 'px');
  }
}
/**
 * 初始化定制平台列表
 * @returns
 */


function initApplyList() {
  //初始化列表操作按钮
  initToolbar(); //初始化基础/高级查询显示

  initSearchView(); //初始化基础查询控件

  initBaseSearch(); //初始化高级查询控件

  initAdvanceSearch(); //初始化列表数据

  initTable(); //重置列表高度

  reloadTableHeight(); //初始化按钮事件

  initApplyEvent();
}
/**
 * 加载某一资源
 * @param resourceId
 * @param menuId
 * @param callback
 * @returns
 */


function initOneResourceData(resourceId, menuId, callback) {
  if (!resourceId) {
    return;
  }

  ; //根据资源Id获取资源包信息

  callBackendMethod("govdocResourceEngineManager", "getPageByResourceId", resourceId, menuId, {
    success: function success(data) {
      if ("__LOGOUT" == data) {
        return;
      }

      if (data.resourceNavurl == null && data.dateSource == null && data.showFields == null) {
        //表明资源已经被删除
        $.alert($.i18n("govdoc.resource.manage.alert.has_deleted_this_and_login_refresh"));
        return;
      } else {
        rowButtonConfig = data.rowButtonConfigVo; // 同一流程只显示一条 是否勾选

        deduplication = data.deduplication;
        $(".tableContainer").removeClass("display_none");
        $(".noData").addClass("display_none");
        $(".noData").text("");
        callback && callback(data);
      }
    },
    error: function error(msg) {
      var responseText = JSON.parse(msg.response).details;
      $(".noData").removeClass("display_none").text(responseText);
      console.log(msg);
    }
  });
}
/**
 * 从撤销回退记录/竞争已办列表中返回
 * @param resourceId
 * @returns
 */


function clickCallback(resourceId) {
  $("#queryIframe").hide(); //返回时需隐藏queryIframe

  _resouceNavClickFun(resourceId);
}
/**
 * 初始化列表操作按钮
 * @returns
 */


function initToolbar() {
  var toolbarButtons = resourceVo.toolbarButtons;
  if (!toolbarButtons) return;
  var datas = [],
      subMenu = [],
      handoverMenu = [];
  $(toolbarButtons).each(function (i, index) {
    if (filterBtnShow(index, index.elementCode)) {
      //按钮过滤成功才能push
      var name = index.name; //转发/转协同/转办/转公告

      if (name == "doForward" || name == "doForwardCol" || name == "turnToRec" || name == "dealTransmitBulletinFunc") {
        subMenu.push({
          type: index.type,
          name: index.showUseLabel,
          id: index.id,
          className: index.css,
          click: function click() {
            filterBtnEvent(index.type);
          }
        });
      } else if (name == "workflowOnlyOne") {
        //同一流程只显示一条
        datas.push({
          id: index.id,
          type: "checkbox",
          name: name,
          text: index.showUseLabel,
          checked: deduplication === "true",
          click: function click() {
            var _this = this;

            _this.checked = !_this.checked;
            resourceVo.deduplication = _this.checked ? "true" : "false";
            deduplication = _this.checked ? "true" : "false";

            if (queryDisplay.advancedQuery) {
              doAdvanceSearch();
            } else {
              searchByCondition({
                page: 1,
                //查询默认为第1页
                condition: getConditionObj() //查询条件

              });
            }
          }
        });
      } else if (name == "handoverToMe" || name == "handoverToOthers") {
        handoverMenu.push({
          type: index.type,
          name: index.showUseLabel,
          id: index.id,
          className: index.css,
          click: function click() {
            filterBtnEvent(index.type);
          }
        });
      } else {
        datas.push({
          type: index.type,
          name: index.showUseLabel,
          id: index.id,
          className: index.css,
          click: function click() {
            if (index.id) {
              toolbar.selected(index.id);
            }

            filterBtnEvent(index.type);
          }
        });
      }
    }
  });

  if (subMenu.length > 1) {
    //合并按钮
    datas.push({
      id: "zhuanfa",
      name: $.i18n("govdoc.resource.manage.forward"),
      type: "zhuanfa",
      className: "ico16 forwarding_16",
      subMenu: subMenu
    }); //转发
  } else {
    datas = datas.concat(subMenu);
  } // 合并定制平台配置的toolbar 交接事项按钮


  if (handoverMenu.length > 1) {
    datas.push({
      id: "handover",
      name: $.i18n("handover.grid.matters.js"),
      type: "handover",
      className: "",
      subMenu: handoverMenu
    }); //交接事项按钮
  } else {
    datas = datas.concat(handoverMenu);
  }

  toolbar = $("#toolbar").toolbar({
    toolbar: datas,
    searchBoxflex: true
  }); //操作按钮展示过滤

  function filterBtnShow(item, code) {
    var type = item.name;
    var dateSource = resourceVo.dataSources[0]; //按钮权限

    if (!dateSource) return;
    var affairState = dateSource.affairState;
    var flag = btnViewProps.get(type); //发文拟文/快速发文/收文登记/签报拟文/归档/撤销流程

    if (typeof flag != 'undefined') {
      return flag;
    } //affairState的判断


    switch (type) {
      case "edit":
        //编辑
        return affairState.filter(function (index) {
          return index === "1";
        }).length;

      case "backfenban":
        //回退分办
        return affairState.filter(function (index) {
          return index === "1";
        }).length;

      case "delete":
        //删除
        return affairState.filter(function (index) {
          return index === "1" || index === "2" || index === "4" || index === "5" || index === "6";
        }).length;

      case "dealTransmitBulletinFunc":
        //转公告
        return affairState.filter(function (index) {
          return index === "2" || index === "4" || index === "11" || index.indexOf("11");
        }).length;

      case "doPigeonhole":
        //归档
        return affairState.filter(function (index) {
          return index === "2" || index === "4";
        }).length;

      case "cancel":
        //撤销流程
        return affairState.filter(function (index) {
          return index === "2";
        }).length;

      case "turnToRec":
        //转办(仅收文)
        return affairState.filter(function (index) {
          return index === "2" || index == "3" || index === "4";
        }).length;

      case "batchEdoc":
        //批处理
        return affairState.filter(function (index) {
          return index === "3";
        }).length;

      case "doForward":
        //转发文(仅收文)
        return affairState.filter(function (index) {
          return index == "3" || index === "4";
        }).length;

      case "doForwardCol":
        //转协同
        return affairState.filter(function (index) {
          return index === "4" || index === "2" || index === "11" || index.indexOf("11");
        }).length;

      case "workflowOnlyOne":
        //同一流程只显示一条
        return affairState.filter(function (index) {
          return index === "3" || index === "4" || index === "11" || index.indexOf("11");
        }).length;

      case "stepBack":
        //撤销回退记录
        return affairState.filter(function (index) {
          return index === "4";
        }).length;

      case "doTakeBack":
        //取回
        return affairState.filter(function (index) {
          return index === "4";
        }).length;

      case "otherGrab":
        //他人竞争事项
        return affairState.filter(function (index) {
          return index === "4";
        }).length;

      case "proxy":
        //代理
        resourceVo.showProxy = "false";
        return true;

      case "clear":
        // 垃圾箱
        return true;

      case "handoverToMe":
        // 交接给我的事项
        resourceVo.showHandover = "false";
        return true;

      case "handoverToOthers":
        // 交接给他人的事项
        resourceVo.showHandover = "false";
        return true;

      default:
        return 0;
    }
  } //操作按钮点击事件过滤


  function filterBtnEvent(_x) {
    return _filterBtnEvent.apply(this, arguments);
  }

  function _filterBtnEvent() {
    _filterBtnEvent = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(type) {
      var _url, tableRows, userId, i, obj, affairState, isSatisfy, reason, statestr, param, size, confirm, archivestate, string;

      return regeneratorRuntime.wrap(function _callee$(_context) {
        while (1) {
          switch (_context.prev = _context.next) {
            case 0:
              _url = resourceUrlProps.get(type);

              if (!(typeof _url != 'undefined')) {
                _context.next = 6;
                break;
              }

              //跳转按钮-直接跳转到url
              if (type == "stepBack") {
                //撤销回退记录
                linkToBackList(_url);
              } else {
                window.open(_url);
              }

              return _context.abrupt("return");

            case 6:
              if (!(type == "otherGrab")) {
                _context.next = 12;
                break;
              }

              //他人处理事项
              resourceVo.isOtherList = "true";
              linkToOtherList();
              return _context.abrupt("return");

            case 12:
              if (!(type == "proxy")) {
                _context.next = 18;
                break;
              }

              //代理
              resourceVo.showProxy = "true";
              doAdvanceSearch();
              return _context.abrupt("return");

            case 18:
              if (!(type == "handoverToMe")) {
                _context.next = 25;
                break;
              }

              // 交接给我的事项
              console.log("点击了 交接给我的事项,显示 交接给我的事项页面 ");
              resourceVo.showHandover = "toMe";
              linkToHandoverList();
              return _context.abrupt("return");

            case 25:
              if (!(type == "handoverToOthers")) {
                _context.next = 30;
                break;
              }

              // 交接给他人的事项
              console.log("点击了 交接给他人的事项,显示 交接给他人的事项 ");
              resourceVo.showHandover = "fromMe";
              linkToHandoverList();
              return _context.abrupt("return");

            case 30:
              tableRows = grid.grid.getSelectRows();

              if (!(!tableRows || tableRows.length == 0)) {
                _context.next = 34;
                break;
              }

              $.error($.i18n("govdoc.resource.manage.needSelectData")); //请先选择一条数据

              return _context.abrupt("return");

            case 34:
              if (!(type == 'batchEdoc' || type == 'delete' || type == 'doPigeonhole' || type == 'doTakeBack' || type == 'backfenban' || type == 'cancel' || type == 'doForward' || type == 'doForwardCol' || type == 'dealTransmitBulletinFunc' || type == 'turnToRec')) {
                _context.next = 45;
                break;
              }

              userId = $.ctx.CurrentUser.id;
              i = 0;

            case 37:
              if (!(i < tableRows.length)) {
                _context.next = 45;
                break;
              }

              obj = tableRows[0];

              if (obj.affairMemberId == userId || obj.proxyMemberId == userId) {
                _context.next = 42;
                break;
              }

              $.error($.i18n("govdoc.resource.manage.dataNotoperation")); //该数据不支持该操作

              return _context.abrupt("return");

            case 42:
              i++;
              _context.next = 37;
              break;

            case 45:
              affairState = tableRows[0].affairState; //1:待发 2:已发 3:待办 4:已办

              isSatisfy = true; //是否满足条件

              reason = 0;
              _context.t0 = type;
              _context.next = _context.t0 === "edit" ? 51 : _context.t0 === "delete" ? 53 : _context.t0 === "clear" ? 56 : _context.t0 === "backfenban" ? 62 : _context.t0 === "doPigeonhole" ? 64 : _context.t0 === "cancel" ? 67 : _context.t0 === "dealTransmitBulletinFunc" ? 69 : _context.t0 === "turnToRec" ? 76 : _context.t0 === "batchEdoc" ? 78 : _context.t0 === "doForward" ? 80 : _context.t0 === "doTakeBack" ? 82 : _context.t0 === "doForwardCol" ? 84 : 86;
              break;

            case 51:
              //编辑
              if (affairState == 1) {
                //待发支持编辑
                openFrom = 'listWaitSend';
                parent._resourceCode = 'F20_govDocSendManage';
                parent._isFromType = 'newEdocConfig';
                doEdit(resourceVo.menuId);
              } else {
                //其它状态不支持
                reason = 1;
                isSatisfy = false;
              }

              return _context.abrupt("break", 86);

            case 53:
              //删除
              statestr = stateProps.get(affairState);

              if (statestr) {
                doDelete(statestr, 'tableContent', aDelProps.get(statestr));
              } else {
                isSatisfy = false;
              }

              return _context.abrupt("break", 86);

            case 56:
              // 垃圾箱删除
              param = "";
              size = tableRows.length;

              for (i = 0; i < size; i++) {
                if (i == size - 1) {
                  param += tableRows[i].affairId;
                } else {
                  param += tableRows[i].affairId + ",";
                }
              }

              confirm = "";
              confirm = $.confirm({
                // 'msg': $.i18n("edoc.clearOperate"),
                'msg': "该操作不能恢复，是否进行清除操作?",
                ok_fn: function ok_fn() {
                  callBackendMethod("govdocResourceEngineManager", "clearData", param, {
                    success: function success(data) {
                      loadPendingGrid();
                    },
                    error: function error(request, settings, e) {
                      $.error(e);
                    }
                  });
                }
              });
              return _context.abrupt("break", 86);

            case 62:
              //回退分办
              if (affairState == 1) {
                //待发支持回退分办(仅收文)
                doTakeDeal();
              } else {
                isSatisfy = false;
              }

              return _context.abrupt("break", 86);

            case 64:
              //归档
              archivestate = archiveProps.get(affairState);

              if (archivestate) {
                //待办/已办/已发支持归档
                doPigeonhole(archivestate, grid, "tableContent");
              } else {
                isSatisfy = false;
              }

              return _context.abrupt("break", 86);

            case 67:
              //撤销流程
              if (affairState == 2) {
                //已发支持撤销
                doCancel();
              } else {
                isSatisfy = false;
              }

              return _context.abrupt("break", 86);

            case 69:
              if (!(affairState == 2 || affairState == 4 || affairState == 8 || affairState == 11)) {
                _context.next = 74;
                break;
              }

              _context.next = 72;
              return dealTransmitBulletinFunc();

            case 72:
              _context.next = 75;
              break;

            case 74:
              isSatisfy = false;

            case 75:
              return _context.abrupt("break", 86);

            case 76:
              //转办(仅收文)
              if (affairState == 2 || affairState == 3 || affairState == 4) {
                //已发/待办/已办支持转办
                turnToRec({
                  successCallback: function successCallback() {
                    if (parent.document.getElementById('resourceDataIframe')) {
                      parent.document.getElementById('resourceDataIframe').contentWindow.location.reload(true);
                    } else if (parent.document.getElementById('mainIframe')) {
                      parent.document.getElementById('mainIframe').contentWindow.location.reload(true);
                    } else if (parent.parent.document.getElementById('mainIframe')) {
                      parent.parent.document.getElementById('mainIframe').contentWindow.location.reload(true);
                    }
                  }
                });
              } else {
                isSatisfy = false;
              }

              return _context.abrupt("break", 86);

            case 78:
              //批处理
              if (affairState == 3) {
                //待办支持批处理
                batchEdoc();
              } else {
                isSatisfy = false;
              }

              return _context.abrupt("break", 86);

            case 80:
              //转发文
              if (affairState == 3 || affairState == 4) {
                //待办/待办支持转发文
                doForward();
              } else {
                isSatisfy = false;
              }

              return _context.abrupt("break", 86);

            case 82:
              //取回
              if (affairState == 4) {
                //已办支持取回
                doTakeBack();
              } else {
                isSatisfy = false;
              }

              return _context.abrupt("break", 86);

            case 84:
              //转协同
              if (affairState == 2 || affairState == 4 || affairState == 8 || affairState == 11) {
                doForwardCol();
              } else {
                isSatisfy = false;
              }

              return _context.abrupt("break", 86);

            case 86:
              if (!isSatisfy) {
                string = $.i18n("govdoc.resource.manage.dataNotoperation");

                if (reason != 0) {
                  string = $.i18n("govdoc.resource.manage.dataNotoperation.reason" + reason);
                }

                $.error(string); //该数据不支持该操作
              }

            case 87:
            case "end":
              return _context.stop();
          }
        }
      }, _callee);
    }));
    return _filterBtnEvent.apply(this, arguments);
  }
}

function getConditionObj() {
  var o = new Object();
  o.listType = listType;

  if (typeof resourceVo.deduplication != "undefined") {
    o.deduplication = resourceVo.deduplication;
  }

  var choose = $('#' + searchobj.p.id).find("option:selected").val();

  if (choose != "") {
    o[choose] = $("li #" + choose).val();
    o.condition = "choose";
  }

  return o;
}
/**
 * 初始化基础查询
 * @param needView
 * @returns
 */


function initBaseSearch(needView) {
  if (!resourceVo.queryDisplay || resourceVo.queryDisplay.advancedQuery) {
    //高级查询
    return;
  } //清除高级查询条件控件


  clearAdvanceSearchContainer();
  var baseSearchColumns = resourceVo.baseSearchColumns;
  var enumsMap = resourceVo.searchEnums;
  var conditions = [];

  for (var i = 0; i < baseSearchColumns.length; i++) {
    var temp = baseSearchColumns[i];
    var condition = {};
    condition.id = temp.elementCode;
    condition.name = temp.elementCode;
    condition.value = temp.elementCode;
    condition.text = temp.showName;
    condition.type = temp.showType == null ? "input" : temp.showType;

    if (condition.type == "datemulti") {
      condition.ifFormat = '%Y-%m-%d';
      condition.dateTime = false;
    } else if (condition.type == "select") {
      if (!enumsMap) {
        condition.items = [{
          "value": "",
          "text": ""
        }];
      } else {
        var itemsArray = eval(enumsMap[temp.elementCode]);

        if (itemsArray != null) {
          var resetItems = new Array();

          for (var j = 0; j < itemsArray.length; j++) {
            var item = itemsArray[j];
            var resetItemMap = {};
            resetItemMap.text = item.name == undefined ? item.text : item.name;
            resetItemMap.value = item.value;
            resetItems.push(resetItemMap);
          }

          condition.items = resetItems;
        }
      }
    } else if (condition.type == "selectPeople") {
      condition.type = "input";
    }

    conditions.push(condition);
  }

  if (conditions.length > 0) {
    searchobj = $.searchCondition({
      top: topSearchSize,
      right: 30,
      searchHandler: function searchHandler() {
        var params = searchobj.g.getReturnValue();

        if (params.value && params.type == "datemulti") {
          params.value = params.value.join("#");
        } else if (params.condition) {
          params.value = $("#" + params.condition).val().trim();
        }

        var condition = {};

        if (params.condition) {
          condition[params.condition] = params.value;
        }

        if (params !== null) {
          params[params.condition] = params.value;
          params.resourceId = resourceVo.resourceId;
          params.condition = condition;
          params.page = 1;
          params.deduplication = deduplication; // 过滤交接给我的数据-查询框

          params.showHandover = resourceVo.showHandover;
          $("#tableContent").ajaxgridLoad(params);
        }
      },
      conditions: conditions
    });
  }
}
/**
 * 初始化高级查询
 * @param needView
 * @returns
 */


function initAdvanceSearch(needView) {
  if (!resourceVo.queryDisplay || !resourceVo.queryDisplay.advancedQuery) {
    //高级查询
    return;
  }

  if (typeof needView == "undefined") {
    //初始化
    needView = resourceVo.queryDisplay.style == "2"; //收起
  }

  if (!needView) {
    return;
  } //加载小查询时清空高级查询的配置


  var searchContainer = $("#searchItemContaier");

  if (searchContainer.html() != "") {
    return;
  }

  clearAdvanceSearchContainer();
  initAdvanceSearchContaier(needView);
}
/**
 * 查询按钮的显示状态
 * @param needView
 * @returns
 */


function initSearchView(needView) {
  if (!resourceVo.queryDisplay) {
    return;
  }

  var searchContent = $(".searchContent");

  if (resourceVo.queryDisplay.advancedQuery) {
    //高级查询
    if (typeof needView == "undefined") {
      //初始化
      needView = resourceVo.queryDisplay.style == "2"; //收起
    }

    if (needView) {
      //展开
      $(".searchDiv").removeClass("display_none");
      $("#searchDiv").text($.i18n("govdoc.resource.manage.putIt"));
      searchContent.removeClass("display_none");
    } else {
      //收起
      $(".searchDiv").removeClass("display_none");
      $("#searchDiv").text($.i18n("govdoc.resource.manage.search")); //搜索

      searchContent.addClass("display_none");
    }
  } else {
    //基础查询
    $(".searchDiv").addClass("display_none");
    $("#searchDiv").addClass("display_none");
    searchContent.addClass("display_none");
  }
}
/**
 * 删除高级查询条件
 * @returns
 */


function clearAdvanceSearchContainer() {
  //加载小查询时清空高级查询的配置
  var searchContainer = $("#searchItemContaier");
  searchContainer.html('');
}
/**
 * 初始化高级查询条件控件
 * @returns
 */


function initAdvanceSearchContaier() {
  var searchContainer = $("#searchItemContaier");
  var advanceSearchColumns = resourceVo.advanceSearchColumns;
  var str = '';
  var typeCache = [];

  for (var i in advanceSearchColumns) {
    var item = advanceSearchColumns[i]; //收文显示来文文号

    if (item.key == 'govdoc.docMark.label') {
      item.key = 'govdoc.communication.number';
    }

    if (item.key) {
      str += '<div class="row_cell col_25">' + '<div class="row_div clearfix small_record fixed_label">' + '<div class="label_cell mid_label" title=' + item.showUseLabel + '>' + item.showUseLabel + '</div> ' + '<div class="content_cell mid_label">' + renderType(item) + '</div>  ' + '</div> ' + '</div>';
    }
  }

  function renderType(item) {
    var enumsMap = resourceVo.searchEnums;
    var html = '';
    var type = item.showType;

    switch (type) {
      case "input":
        //文本类型
        typeCache.push({
          type: type
        });
        html += "<div class='common_txtbox_wrap'>" + "<input type='text' class='searchInput' id='" + item.name + "' name='" + item.name + "' autocomplete='off' class='validate comp' />" + "</div>";
        break;

      case "select":
        //下拉类型
        var options = eval(enumsMap[item.elementCode]);
        html += "<div class='common_txtbox_wrap'>" + "<select class='comp_select searchInput searchSelect' id='" + item.name + "' name='" + item.name + "' >";
        html += "<option value=''></option>";

        for (var i = 0, len = options.length; i < len; i++) {
          var option = options[i];
          html += "<option value='" + option.value + "'>" + option.name + "</option>";
        }

        html += "</select>" + "</div>";
        break;

      case "datemulti":
        //时间类型
        html += "<div class='common_txtbox_wrap dateItemType'>" + "<input type='text' id='" + item.name + "' class='searchInput searchDate validate msHideClear ' value='' name='" + item.name + "' autocomplete='off' />" + "</div>";
        break;

      case "number":
        //数字类型
        html += "<div class='common_txtbox_wrap'> " + "<input type='number' id='" + item.name + "' autocomplete='off' class='searchInput' name='" + item.name + "' value='" + item.value + "'>  " + "</div> ";
        break;

      case "selectPeople":
        //选人组件
        var isMax = false;

        if (item.name == "currentNodesInfo") {
          //当前待办人
          isMax = true;
        }

        html += "<div class='common_txtbox_wrap'> " + "<input type='text' readonly='true' autocomplete='off' isMax='" + isMax + "' id='" + item.name + "' name='" + item.name + "' class='searchInput selectPeople comp' comp='type:'selectPeople',mode:'open''/>" + "</div>";
        break;

      case "checkbox":
        //复选组件
        var checkDatas = [];
        html += "<div class='common_txtbox_wrap'> ";
        $(checkDatas).each(function (i, index) {
          html += "<span class='ctpUiCheckbox'>" + "<input type='checkbox' name='" + item.name + "' value='1' id='" + item.name + "' checked>" + "<label for='" + item.name + "'><i></i>'" + item.value + "'</label>" + "</span>";
        });
        html += "</div> ";
        break;

      case "other":
        //节点权限
        html += "<div class='common_txtbox_wrap'> " + "<input type='text' class='searchInput dialog' autocomplete='off' id='" + item.name + "' name='" + item.name + "' value='" + (item.value || '') + "'>  " + "</div> ";
        break;

      default:
        html += "<div class='common_txtbox_wrap'>" + "<input type='text' class='searchInput' id='" + item.name + "' name='" + item.name + "' autocomplete='off' class='validate comp' />" + "</div>";
        break;
    }

    return html;
  }

  function initContainerControl() {
    //下拉类型初始化
    var searchSelectDom = $(".searchSelect");
    searchSelectDom && searchSelectDom.length > 0 && searchSelectDom.each(function (i, index) {
      searchSelectMap[$(index).attr("name")] = new CtpUiComSelect($("#" + $(index).attr("id")).get(0), {
        containerId: "mainPage"
      });
    }); //时间类型初始化

    var searchDateDom = $(".searchDate");
    searchDateDom && searchDateDom.length > 0 && searchDateDom.each(function (i, index) {
      var getDate = getDateFun();
      var name = $(index).attr("name");
      searchDateMap[name] = new CtpUiDateRange($(index).attr("id"), {
        twoInput: true,
        hasIcon: true,
        type: "date"
      });
      $(index).click(function () {
        if (preview) {
          return;
        }

        ;
        var name = $(this).attr("name");

        var _time = searchDateMap[name].getDateValues();

        var startDate = _time.startDate || getDate;
        var endDate = _time.endDate || getDate;

        if ($(this).val() == "") {
          startDate = getDate;
          endDate = getDate;
        }

        searchDateMap[name].setDateValues({
          startDate: startDate,
          endDate: endDate
        });
      });
      $(index).prev().click(function () {
        if (preview) {
          return;
        }

        ;
        var name = $(this).next().attr("name");

        var _time = searchDateMap[name].getDateValues();

        var startDate = _time.startDate || getDate;
        var endDate = _time.endDate || getDate;

        if ($(this).next().val() == "") {
          startDate = getDate;
          endDate = getDate;
        }

        searchDateMap[name].setDateValues({
          startDate: startDate,
          endDate: endDate
        });
      });
    }); //选人组件初始化

    var selectPeopleDom = $(".selectPeople");
    selectPeopleDom && selectPeopleDom.length > 0 && selectPeopleDom.each(function (i, index) {
      $(index).click(function () {
        if (preview) {
          return;
        }

        ;

        var _this = this;

        var defValue = $(_this).attr("ids") || "";
        var isMax = $(_this).attr("isMax");
        $.selectPeople({
          type: 'selectPeople',
          params: {
            value: defValue
          },
          panels: 'Account,Department,Outworker,Team,Level,BusinessDepartment',
          selectType: 'Member',
          minSize: 0,
          maxSize: isMax == "true" ? 100 : 1,
          callback: function callback(ret) {
            var _idArr = [];

            if (ret != undefined && ret.obj.length > 0) {
              for (var i = 0; i < ret.obj.length; i++) {
                _idArr.push(ret.obj[i].id);
              }
            }

            var _id = _idArr.join(",");

            searchSelectPeople[$(_this).attr("name")] = _id;
            $(_this).attr("value", _id);
            $(_this).attr("ids", ret.value);
            $(_this).val(ret.text);
          }
        });
      });
    }); //节点权限选择

    var permissionDom = searchContainer.find(".searchInput.dialog");

    if (permissionDom && permissionDom.length > 0) {
      // 先获取节点权限数据
      var permissionList = null;
      callBackendMethod("govdocResourceEngineManager", "getGovdocNodePerssionItem", {
        success: function success(jsonObj) {
          if (typeof jsonObj === "string") {
            if (jsonObj == "__LOGOUT") {
              return;
            }

            try {
              permissionList = parseJSON(jsonObj);

              if (typeof permissionList === "number") {
                permissionList = jsonObj;
              }
            } catch (e) {
              if (window.console && window.console.log) {}

              permissionList = jsonObj;
            }
          } else {
            permissionList = jsonObj;
          }
        },
        error: function error(err) {}
      }); // 再绑定节点权限点击事件

      var selectedItemsMap = ["", "", "", ""];
      permissionDom.each(function (i, index) {
        $(index).click(function () {
          if (!permissionList) {
            return;
          }

          if ($(this).val() == "") {
            //如果数据是空-弹出的节点权限里去掉所有已选数据
            selectedItemsMap = ["", "", "", ""];
          }

          var _this = this;

          var modulePermissionList = [{
            module: 'send',
            data: []
          }, {
            module: 'receive',
            data: []
          }, {
            module: 'sign',
            data: []
          }, {
            module: 'exchange',
            data: []
          }];
          permissionList.forEach(function (item) {
            if (item.category === 'edoc_new_send_permission_policy') {
              modulePermissionList[0].data.push(item);
            } else if (item.category === 'edoc_new_rec_permission_policy') {
              modulePermissionList[1].data.push(item);
            } else if (item.category === 'edoc_new_qianbao_permission_policy') {
              modulePermissionList[2].data.push(item);
            } else if (item.category === 'edoc_new_change_permission_policy') {
              modulePermissionList[3].data.push(item);
            }
          });
          var params = {};
          params.selectList = ["send", "receive", "sign", "exchange"]; //

          params.selectedItems = selectedItemsMap;
          params.itemsObj = modulePermissionList;
          params.isEdit = true;
          var permissionDialog = $.dialog({
            id: "itemsDialog",
            url: _ctxPath + "/govdoc/resourceEngine.do?method=resourceNodeSelect",
            title: $.i18n("govdoc.select.node.permission"),
            //请选择节点权限
            width: 645,
            height: 430,
            targetWindow: window.top,
            isClear: false,
            transParams: params,
            buttons: [{
              isEmphasize: true,
              id: "okButton",
              text: $.i18n('common.button.ok.label'),
              handler: function handler() {
                selectedItemsMap = ["", "", "", ""];
                var data = permissionDialog.getReturnValue();
                var selectMap = {};
                hasSelected = false;

                for (var i = 0, len = data.length; i < len; i++) {
                  if (data[i] != null && data[i] != "") {
                    selectMap[i] = data[i];
                    hasSelected = true;
                    selectedItemsMap[i] = data[i];
                  }
                }

                if (!hasSelected) {
                  $(_this).attr("selectValue", "");
                  $(_this).val("");
                } else {
                  $(_this).attr("selectValue", JSON.stringify(selectMap));
                  $(_this).val($.i18n("govdoc.resource.manage.selected")); //已选择
                }

                permissionDialog.close();
              }
            }, {
              id: "cancelButton",
              text: $.i18n('govdoc.shutdown'),
              handler: function handler() {
                permissionDialog.close();
              }
            }]
          });
        });
      });
    }
  }

  clearAdvanceSearchContainer();
  $("#searchItemContaier").html(str); //下拉类型初始化

  initContainerControl();
}

function initApplyEvent() {
  //搜索按钮点击事件-切换搜索区域的显示或隐藏
  var searchContent = $(".searchContent"); //基础查询

  $("#searchDiv").unbind("click").on("click", function () {
    var needView = searchContent.hasClass("display_none");
    initSearchView(needView);
    initAdvanceSearch(needView);
    reloadTableHeight();
  }); //点击查询按钮，执行搜索操作
  //高级查询-确认

  $("#searchSubmit").unbind("click").on("click", function () {
    doAdvanceSearch();
  }); //点击重置按钮，取消搜索
  //高级查询-取消

  $("#searchCancel").unbind("click").on("click", function () {
    var searchInput = $(".searchInput");
    searchInput.each(function (i, index) {
      var name = index.getAttribute("name");
      this.value = "";
      var selectDomMap = searchSelectMap[name]; //下拉数据

      var dateDomMap = searchDateMap[name]; //时间

      var peopleDomMap = searchSelectPeople[name]; //选人

      if (selectDomMap) {
        selectDomMap.setValue("");
      } else if (dateDomMap) {
        searchDateMap[name].setDateValues({
          startDate: "",
          endDate: ""
        });
      } else if (peopleDomMap) {
        searchSelectPeople[name] = "";
      } else if (name === "affairNodePolicy") {
        //节点权限重置
        index.setAttribute("value", "");
      }
    });
  });
} //执行搜索


function doAdvanceSearch() {
  var searchInput = $(".searchInput");
  var condition = {};
  searchInput && searchInput.length > 0 && searchInput.each(function (i, index) {
    var name = index.getAttribute("name");
    var selectMap = searchSelectMap[name],
        dateMap = searchDateMap[name],
        selectPeople = searchSelectPeople[name];

    if (selectMap) {
      //获取下拉类型
      var selValue = selectMap.getSelValue();
      var value = selValue && selValue.length > 0 ? selValue[0] : "";
      value && (condition[name] = value);
    } else if (dateMap) {
      //获取时间类型
      var startTime = dateMap.getStartDate(),
          endTime = dateMap.getEndDate();

      if (startTime && endTime) {
        var timeValue = startTime + "#" + endTime;
        timeValue && (condition[name] = timeValue);
      }
    } else if (selectPeople) {
      //选人
      selectPeople && (condition[name] = selectPeople);
    } else if (name === "affairNodePolicy") {
      //节点权限
      var selectValue = index.getAttribute("selectValue");
      selectValue && (condition[name] = selectValue);
    } else {
      index.value && (condition[name] = index.value);
    }
  });
  searchByCondition({
    page: 1,
    //查询默认为第1页
    condition: condition //查询条件

  });
}
/**
 * 根据条件查询列表数据
 * @param 
 * @returns
 */


function searchByCondition(o) {
  o.deduplication = resourceVo.deduplication;
  o.resourceId = resourceVo.resourceId;
  o.showProxy = resourceVo.showProxy;
  o.showHandover = resourceVo.showHandover;
  $("#tableContent").ajaxgridLoad(o);
}

function tableReload() {
  $("#tableContent").ajaxgridLoad();
} //处理刷新


function loadPendingGrid() {
  $("#tableContent").ajaxgridLoad();
}

function initTable() {
  destoryTable();
  var colModels = listTable.getTableColModels();
  var colNames = listTable.getTableColNames();
  var options = {
    click: listTable.rowClick,
    //单击事件
    dblclick: function dblclick(data, rowIndex, colIndex) {},
    //双击事件
    render: listTable.rend,
    //function rend(txt,rowData, rowIndex, colIndex,colObj)
    colNames: colNames,
    colModel: colModels,
    page: 1,
    height: document.body.offsetHeight - 165,
    managerName: "govdocResourceEngineManager",
    //后台接口 后台Manager的名称 -必填
    managerMethod: "getFrontResouceList",
    //后台接口 后台对应Manager的方法名 -必填
    usepager: true,
    //是否需要分页
    showToggleBtn: true,
    //显示/隐藏表头下拉箭头
    callBackTotle: page.data.getCount,
    resizable: false
  };

  if (typeof tabId !== 'undefined') {
    options.customId = $.ctx._currentPathId_ + tabId;
  }

  grid = $("#tableContent").ajaxgrid(options); //加载列表

  var condition = new Object();
  condition.resourceId = resourceVo.resourceId;
  condition.showProxy = resourceVo.showProxy;
  condition.showHandover = resourceVo.showHandover;
  searchByCondition({
    page: 1,
    //查询默认为第1页
    condition: condition //查询条件

  });
}
/**
 * 跳转按钮-进入撤销回退列表
 * @param _url
 * @returns
 */


function linkToBackList(_url) {
  callBackendMethod("govdocResourceEngineManager", "getGovDocTypeByResourceId", resourceVo.resourceId, {
    success: function success(data) {
      _url = _url + data;
      $("#queryIframe").show();
      $(".container").hide();
      $("#queryIframe").attr("src", _url);
    },
    error: function error(request, settings, e) {
      $.error(e);
    }
  });
}

function ListTable() {
  var _this = this;

  _this.colModels = new Array();
  _this.colNames = new Array();

  _this.initColumns = function () {
    if (_this.colModels && _this.colModels.length > 0) {
      return;
    }

    var widthLen = resourceVo.tableColumns.length;
    var tableW = 100 / widthLen + "%";

    if (widthLen > 8) {
      tableW = "15%";
    }

    _this.colModels.push({
      display: 'id',
      name: 'orgid',
      width: '40',
      align: 'center',
      type: 'checkbox'
    });

    $(resourceVo.tableColumns).each(function (i, index) {
      //收文显示来文文号
      if (index.key == "govdoc.docMark.label" && isOnlyRec() == true) {
        index.key = 'govdoc.communication.number';
      }

      _this.colModels.push({
        display: $.i18n(index.showName),
        name: index.name,
        width: tableW,
        slideToggleBtn: true,
        align: 'left'
      });

      _this.colNames.push(index.name);
    });
  };

  _this.getTableColNames = function () {
    _this.initColumns();

    return _this.colNames;
  };

  _this.getTableColModels = function () {
    _this.initColumns();

    return _this.colModels;
  };

  _this.rowClick = function (data, rowIndex, colIndex) {
    if (colIndex == 11) {
      return;
    } // 取消加粗


    cancelBold("tableContent", rowIndex);

    if (!isAffairValid(data.affairId)) {
      $("#tableContent").ajaxgridLoad();
      return;
    }

    var from = "listCustom";

    if (data.affairMemberId == $.ctx.CurrentUser.id || data.proxyMemberId == $.ctx.CurrentUser.id) {
      if (data.affairState == 1) {
        //待发
        from = "listWaitSend";
      } else if (data.affairState == 2) {
        //已发
        from = "listSent";
      } else if (data.affairState == 3) {
        //待办
        from = "listPending";
      } else if (data.affairState == 4) {
        //已办
        from = "listDone";
      } else if (data.affairState == 5) {
        //撤销
        from = "repealRecord";
      } else if (data.affairState == 6) {
        //回退
        from = "stepBackRecord";
      }
    }

    data.menuId = resourceVo.menuId;
    data.parentMenuId = typeof parentMenuId == "undefined" ? parent.paramId : parentMenuId;

    var _url = getListClickUrl(data, from);

    if (!_url) {
      return;
    } //老公文收文登记单
    //old_edocRegister(ApplicationCategoryEnum.edoc, ApplicationCategoryEnum.edocRegister.key()),


    if (data.affairApp === 4 && data.affairSubApp === 24) {
      var pw = parent.window;

      if (window.location.href.indexOf("showConfigData") > -1) {
        pw = window;
        window.location.href = _url;
      } else {
        if (pw && pw.document.getElementById('resourceDataIframe') != null) {
          pw.document.getElementById('resourceDataIframe').src = _url;
        } else {
          parent.window.location.href = _url;
        }
      }
    } else {
      openGovdocDialog(_url, escapeStringToHTML(data.subject));
    }
  };

  _this.rend = function (txt, rowData, rowIndex, colIndex, colObj) {
    if (null == txt) {
      txt = "";
    }

    if (colObj.name === "govdocType") {
      //分类
      if (rowData.govdocType == "4") {
        txt = $.i18n("govdoc.ex.label");
      } else {
        txt = getListGovdocTypeName(rowData.govdocType, rowData.affairSubApp);
      }
    } else if (colObj.name === "subject" || colObj.name === "affairSubject" || colObj.name === "elementSubject") {
      //标题
      var isFlowState = true;

      if (rowData.affairState !== undefined && rowData.affairState == 1 || rowData.affairState == 5 || rowData.affairState == 6) {
        isFlowState = false;
      }

      txt = getListSubjectTxt(txt, rowData, true, true, true, true, true, isFlowState, true, true);
    } else if (colObj.name === "currentNodesInfo") {
      //当前待办人
      txt = getCurrentNodesInfoTxt(txt, rowData, true);
    } else if (colObj.name === "hasArchive") {
      // 是否归档
      if (txt == true) {
        txt = $.i18n('govdoc.canArchive.label.yes');
      } else {
        txt = $.i18n('govdoc.canArchive.label.no');
      }
    } else if (colObj.name === "govdocExchangeMainId") {
      //分送状态
      //发文才有转办记录
      if (rowData.affairSubApp == 1) {
        txt = getListDistributeStateTxt(rowData);
      } else {
        txt = '';
      }
    } else if (colObj.name === "summaryDeadLineName") {
      //流程期限
      txt = txt.substring(0, 21);
      txt = getListSummaryIsCoverTimeTxt(txt, rowData);
    } else if (colObj.name === "affairTrack") {
      //跟踪状态
      if (rowData.affairState == 2) {
        txt = getListTrackTxt(txt, rowData, true);
      } else if (rowData.affairState == 4) {
        txt = getListTrackTxt(txt, rowData, false);
      } else {
        txt = "";
      }
    } else if (colObj.name === "processId") {
      //流程日志
      txt = getListProcessIdTxt(rowData);
    } else if (colObj.name === "keepPeriod") {
      //保密期限
      if (rowData.keepPeriodTxt != null) {
        txt = rowData.keepPeriodTxt;
      } else {
        txt = "";
      }
    } else if (colObj.name === "state") {
      //状态(待发状态)
      if (rowData.affairSubState == 1 || rowData.affairSubState == 2 || rowData.affairSubState == 3 || rowData.affairSubState == 7 || rowData.affairSubState == 16 || rowData.affairSubState == 18) {
        txt = getListWaitState(txt, rowData);

        if (txt.indexOf("substate") > -1) {
          txt = "";
        }
      } else {
        txt = "";
      }
    } else if (colObj.name === "backFromName") {
      //回退人
      txt = rowData.backFromName;
    } else if (colObj.name === "startUserName") {
      //发起人
      if (rowData.affairState == 3) {
        //待办并超期 显示红色名字，参考listPending.js
        txt = getListRedColorTxt(txt, rowData);
      }
    } else if (colObj.name === "affairDeadLineName") {
      // 处理期限（节点期限）
      txt = getListRedColorTxt(txt, rowData);
    } else if (colObj.name === "surplusTime") {
      //办理剩余时间
      txt = getListSurplusTimeTxt(rowData);
    } else if (colObj.name == "affairHastenTimes") {
      //催办次数
      if (rowData.hastenTimes == null || rowData.hastenTimes == "") {
        txt = "0";
      } else {
        txt = rowData.hastenTimes;
      }
    } else if (colObj.name == "exchangeSendAffairId" || colObj.name == "turnRecUserId") {
      //是否分送或是否转办
      if (txt != null && txt != "-1" && txt != "") {
        txt = $.i18n('govdoc.canArchive.label.yes');
      } else {
        txt = $.i18n('govdoc.canArchive.label.no');
      }
    } else if (colObj.name == "handleState") {
      //处理状态
      if (txt == 1) {
        //待发
        txt = $.i18n('govdoc.pending.exSend.text');
      } else if (txt == 2) {
        //已发
        txt = $.i18n('govdoc.Already.send');
      } else if (txt == 3) {
        //待办
        txt = $.i18n('govdoc.to-do');
      } else if (txt == 4) {
        //已办
        txt = $.i18n('govdoc.Already.done');
      } else {
        txt = "";
      }
    } else if (colObj.name == "rowButton") {
      //操作
      txt = getRowButtonTxt(rowData, rowButtonConfig);
    } else if (colObj.name == "transferRecord") {
      //转办记录
      //收文才有转办记录
      if (rowData.affairSubApp == 2) {
        txt = getListDistributeStateTxt(rowData);
      } else {
        txt = '';
      }
    } else if (colObj.name === "signOfDocIssuingAgency") {
      txt = rowData.signatureOfDocIssuingAgency;
    } else if (colObj.name === "summaryIsCoverTime") {
      if (rowData.summaryIsCoverTime) txt = $.i18n('govdoc.canArchive.label.yes');else txt = $.i18n('govdoc.canArchive.label.no');
    } else if (colObj.name === "summaryState") {
      //参考 com.seeyon.apps.edoc.constants.EdocConstant.flowState
      if (txt == 0) {
        txt = $.i18n('govdoc.resource.resourceConfig.processStatus.circulation');
      } else if (txt == 1) {
        txt = $.i18n('govdoc.resource.resourceConfig.processStatus.terminated');
      } else if (txt == 3) {
        txt = $.i18n('govdoc.resource.resourceConfig.processStatus.over');
      } else if (txt == 2) {
        txt = $.i18n('govdoc.revoke.already');
      }
    }

    txt = txt == null || txt == "null" ? "" : txt; //公文元素的日期格式不需要时分

    if (txt != "" && (colObj.name == "registerDate" || colObj.name == "signingDate" || colObj.name == "packTime" || colObj.name == "receiptDate" || colObj.name == "registrationDate" || colObj.name == "startTime")) {
      txt = txt.substring(0, 10);
    } //未读加粗显示


    if (rowData.affairMemberId == $.ctx.CurrentUser.id) {
      txt = getListBoldTxt(txt, rowData);
    } //txt = setGreyTxt(txt, rowData);


    return txt;
  };
}
/**
 * 重置列表高度
 * @returns
 */


function reloadTableHeight() {
  var searchContent = $(".searchContent");
  var searchContentH = searchContent.height() + 30;
  var height = document.body.offsetHeight - (searchContent.hasClass("display_none") ? 185 : 185 + searchContentH);
  $(".bDiv").height(height);
}
/**
 * 销毁表格
 * @returns
 */


function destoryTable() {
  if (grid) {
    $("#" + grid.p["id"]).remove();
    $(".tableContainer").html('<table id="tableContent" tableToken="resourceQueryIndex" class="flexme3" border="0" cellspacing="0" cellpadding="0" ></table>');
  }
}
/**
 * 初始化某一资源的参数
 * @param data
 * @param resourceId
 * @returns
 */


function initOneResourceVo(data, resourceId) {
  resourceVo.resourceId = resourceId;
  resourceVo.showProxy = "false";
  resourceVo.deduplication = deduplication; //初始化权限数据

  initPermission(data); //初始化静态参数

  initProps(); //初始化Toolbar配置数据

  initToolbarButtons(data); //初始化查询配置数据

  initSearchColumns(data); //初始化列表配置数据

  initTableColumns(data);
  listTable = new ListTable();

  function initPermission() {
    permission = {
      actionArchive: data.actionArchive,
      //归档
      actionCancel: data.actionCancel,
      dateSource: data.dateSource,
      zhuanfawen: data.zhuanfawen
    };
    resourceVo.permission = permission;
  }

  function initSearchColumns(data) {
    //查询方式
    queryDisplay = eval('(' + data.queryDisplay + ')');
    resourceVo.queryDisplay = queryDisplay; //遍历搜索条件集合

    var baseSearchColumns = new Array();
    var advanceSearchColumns = new Array();
    var showParams = data.showParams,
        params = data.params;
    showParams && $(showParams).each(function (i, index) {
      advanceSearchColumns[index] = params[index];
      baseSearchColumns.push(params[index]);
    });
    resourceVo.advanceSearchColumns = advanceSearchColumns; //var baseSearchColumns = data.searchColumns == "" ? [] : eval(data.searchColumns);

    resourceVo.baseSearchColumns = baseSearchColumns; //枚举类型数据重构

    var searchEnums;
    var baseSearchEnums = [];
    var advanceSearchEnums = [];
    var enmusMap = data.enmusMap;

    if (enmusMap) {
      var keys = Object.keys(enmusMap);

      if (keys.length > 0) {
        searchEnums = enmusMap;
        advanceSearchEnums = enmusMap;

        for (var i = 0; i < keys.length; i++) {
          baseSearchEnums[i] = eval(enmusMap[keys[i]]);
        }
      }
    }

    resourceVo.baseSearchEnums = baseSearchEnums;
    resourceVo.advanceSearchEnums = advanceSearchEnums;
    resourceVo.searchEnums = searchEnums;
  }

  function initToolbarButtons(data) {
    //遍历按钮展示数据集合
    var toolbarButtons = new Array();
    var showButtons = data.showButtons,
        buttons = data.buttons;
    showButtons && $(showButtons).each(function (i, index) {
      var toolConfig = {
        type: index,
        key: buttons[index].key,
        showUseLabel: buttons[index].showUseLabel,
        name: buttons[index].name,
        css: buttons[index].css,
        elementCode: buttons[index].elementCode
      };

      if (index == "proxy") {
        toolConfig.id = index;
      }

      toolbarButtons.push(toolConfig);
    });
    resourceVo.toolbarButtons = toolbarButtons;
  }

  function initTableColumns(data) {
    //遍历表格字段
    var tableColumns = new Array();
    var showFields = data.showFields;
    var fields = data.fields;
    showFields && $(showFields).each(function (i, index) {
      tableColumns.push({
        key: fields[index].key,
        showName: fields[index].showName,
        name: fields[index].name,
        css: fields[index].css,
        elementCode: fields[index].elementCode
      });
    });
    resourceVo.tableColumns = tableColumns;
  }
}
/**
 * 判断是否为公文拟文资源
 * @returns
 */


function isNewGovResource() {
  return resourceVo.resourceId == "-2063501733767461525" || //快速发文
  resourceVo.resourceId == "2718897185706164469" || //发文拟文
  resourceVo.resourceId == "328301195683972076" || //收文登记
  resourceVo.resourceId == "-6954715937605598651"; //签报拟文
}
/**
 * 判断数据源配置是否只是收文
 * @returns
 */


function isOnlyRec() {
  var dateSource = resourceVo.dataSource;
  var affairSubApp = dateSource.affairSubApp;

  if (affairSubApp == undefined || affairSubApp == null) {
    return false;
  }

  if (affairSubApp == "2,20") {
    return true;
  }

  if (affairSubApp instanceof Array) {
    //收文管理预置的类型
    if (affairSubApp[0] == "2,20" && affairSubApp[1] == "4") {
      return true;
    }
  }

  return false;
}
/**
 * 获取当前配置资源的模块
 * @param params
 */


function getSubApp() {
  var dateSource = permission.dateSource;
  var affairSubApp = dateSource.affairSubApp;
  var govdocType = "";

  if (affairSubApp.indexOf("1,19") != -1) {
    govdocType = govdocType + "1,";
  }

  if (affairSubApp.indexOf("2,20") != -1) {
    govdocType = govdocType + "2,";
  }

  if (affairSubApp.indexOf("3,21") != -1) {
    govdocType = govdocType + "3,";
  }

  if (affairSubApp.indexOf("4") != -1) {
    govdocType = govdocType + "4,";
  }

  if (govdocType.length > 1) {
    govdocType = govdocType.substring(0, govdocType.length - 1);
  }

  return govdocType;
}
/**
 * 获取当前日期格式
 * @returns
 */


function getDateFun() {
  var newDate = new Date();
  var year = newDate.getFullYear(),
      m = newDate.getMonth() + 1,
      d = newDate.getDate();
  return year + "-" + (m < 10 ? "0" + m : m) + "-" + (d < 10 ? "0" + d : d);
}
/**
 * 初始化常量
 */


var resourceUrlProps = new Properties();
var fromProps = new Properties();
var btnViewProps = new Properties();
var archiveProps = new Properties();
var stateProps = new Properties();
var aDelProps = new Properties();

function initProps() {
  resourceUrlProps.put("fawenniwen", _ctxPath + "/govdoc/govdoc.do?method=newGovdoc&sub_app=1&_resourceCode=F20_newSend"); //发文拟文

  resourceUrlProps.put("quickSend", _ctxPath + "/govdoc/govdoc.do?method=newGovdoc&sub_app=1&isQuickSend=true&_resourceCode=F20_fawenNewQuickSend"); //快速发文

  resourceUrlProps.put("receiveSign", _ctxPath + "/govdoc/govdoc.do?method=newGovdoc&sub_app=2&_resourceCode=F20_newDengji"); //收文登记

  resourceUrlProps.put("qianbaoniwen", _ctxPath + "/govdoc/govdoc.do?method=newGovdoc&sub_app=3&_resourceCode=F20_newSign"); //签报拟文

  resourceUrlProps.put("stepBack", _ctxPath + "/supervise/supervise.do?method=listRecord&resourceCode=" + resourceVo.resourceId + "&app=4&record=stepBackRecord&openFrom=listDone&listType=listDoneAll&govdocType=");
  fromProps.put(1, "listWaitSend"); //待发

  fromProps.put(2, "listSent"); //已发

  fromProps.put(3, "listPending"); //待办

  fromProps.put(4, "listDone"); //已办

  fromProps.put(5, "repealRecord"); //撤销

  btnViewProps.put("fawenniwen", sendEdocRoleFromBack == "true"); //发文拟文

  btnViewProps.put("quickSend", edocQuickSendRoleFrromBack == "true"); //快速发文

  btnViewProps.put("receiveSign", recEdocRole == "true"); //收文登记

  btnViewProps.put("qianbaoniwen", signEdocRole == "true"); //签报拟文

  btnViewProps.put("doPigeonhole", resourceVo.permission.actionArchive == 'true'); //归档

  btnViewProps.put("cancel", resourceVo.permission.actionCancel == 'true'); //撤销流程

  archiveProps.put(2, "govdocsent"); //已发

  archiveProps.put(4, "govdocdone"); //已办

  archiveProps.put(3, "pending"); //待办

  aDelProps.put("draft", "listWaitSend"); //待发

  aDelProps.put("sent", "listSent"); //已发

  aDelProps.put("finish", "listDone"); //已办

  stateProps.put(1, "draft"); //待发

  stateProps.put(2, "sent"); //已发

  stateProps.put(4, "finish"); //已结束

  stateProps.put(5, "finish"); //已撤销

  stateProps.put(6, "finish"); //已回退	
}